home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / oldwish / RCS / wishSelect.c,v < prev    next >
Encoding:
Text File  |  1989-01-11  |  21.5 KB  |  910 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.4
  10. date     89.01.11.11.58.41;  author mlgray;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     88.11.03.19.45.28;  author mlgray;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     88.11.02.14.50.58;  author mlgray;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     88.10.03.12.48.42;  author mlgray;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @X11: works pretty much now.
  32. @
  33.  
  34.  
  35. 1.4
  36. log
  37. @Temporary checkin
  38. @
  39. text
  40. @/* 
  41.  * wishSelect.c --
  42.  *
  43.  *    Routines for selection of listed files and groups.
  44.  *
  45.  * Copyright 1987 Regents of the University of California
  46.  * All rights reserved.
  47.  * Permission to use, copy, modify, and distribute this
  48.  * software and its documentation for any purpose and without
  49.  * fee is hereby granted, provided that the above copyright
  50.  * notice appear in all copies.  The University of California
  51.  * makes no representations about the suitability of this
  52.  * software for any purpose.  It is provided "as is" without
  53.  * express or implied warranty.
  54.  */
  55.  
  56. #ifndef lint
  57. static char rcsid[] = "$Header: /a/newcmds/wish/RCS/wishSelect.c,v 1.3 88/11/03 19:45:28 mlgray Exp Locker: mlgray $ SPRITE (Berkeley)";
  58. #endif not lint
  59.  
  60.  
  61. #include "sx.h"
  62. #include "string.h"
  63. #include "wishInt.h"
  64.  
  65. /*
  66.  * Forward references for procedures defined below.
  67.  */
  68. extern    void    WishSelChange();
  69. extern    int    WishSelFetch();
  70.  
  71.  
  72. /*
  73.  *----------------------------------------------------------------------
  74.  *
  75.  * WishChangeSelection --
  76.  *
  77.  *    Change the selection variable.
  78.  *
  79.  * Results:
  80.  *    None.
  81.  *
  82.  * Side effects:
  83.  *    The selection variable is modified.
  84.  *
  85.  *----------------------------------------------------------------------
  86.  */
  87. void
  88. WishChangeSelection(aWindow, clientData, fileP, lineP, addToP)
  89.     WishWindow    *aWindow;
  90.     ClientData        clientData;
  91.     Boolean        fileP;    /* selecting a file or a group? */
  92.     Boolean        lineP;    /* select a whole line, or just file name? */
  93.     Boolean        addToP;    /* just change sel. status of one entry */
  94. {
  95.     WishFile    *filePtr;
  96.     WishGroup    *groupPtr;
  97.     WishSelection    *selPtr, *backPtr;
  98.  
  99.     if (fileP) {
  100.     filePtr = (WishFile *) clientData;
  101.     } else {
  102.     groupPtr = (WishGroup *) clientData;
  103.     }
  104.  
  105.     if (lineP) {
  106.     aWindow->notifierP = TRUE;
  107.     Sx_Notify(wishDisplay, aWindow->surroundingWindow, -1, -1, 0,
  108.         "Line-mode selection temporarily disabled.",
  109.         NULL, TRUE, "Continue", (char *) NULL);
  110.     aWindow->notifierP = FALSE;
  111.     return;
  112.     }
  113.     
  114.     if (fileP) {
  115.     if (!addToP) {
  116.         if (filePtr->selectedP && !lineP) {
  117.         WishClearWholeSelection(aWindow);
  118.         return;
  119.         } else {        /* make the new selection */
  120.         /* check if it's already selected and needs lineP changed. */
  121.         if (filePtr->selectedP == TRUE) {
  122. #ifdef NOTDEF
  123.             for (selPtr = aWindow->selectionList; selPtr != NULL;
  124.                 selPtr = selPtr->nextPtr) {
  125.             if (selPtr->selected.filePtr == filePtr) {
  126.                 break;
  127.             }
  128.             }
  129.             if (selPtr == NULL) {
  130.             sprintf(wishErrorMsg, "%s%s%s", "The selected file `",
  131.                 filePtr->name,
  132.                 "' couldn't be found on the selection list.");
  133.             Sx_Panic(wishDisplay, wishErrorMsg);
  134.             }
  135.             filePtr->lineP = lineP;
  136.             selPtr->lineP = lineP;
  137.             WishRedrawFile(aWindow, filePtr);
  138.             return;
  139. #endif NOTDEF
  140.         }
  141.         /* new selection */
  142.         WishClearWholeSelection(aWindow);
  143.         /*
  144.          * After the first time, Sx_SelectionSet will call
  145.          * WishSelChange, which calls WishClearWholeSelection().
  146.          * This is a warning...
  147.          */
  148.         Sx_SelectionSet(wishDisplay, WishSelFetch, WishSelChange,
  149.             (ClientData) aWindow);
  150.         Tcl_SetVar(aWindow->interp, "sel", filePtr->name, 1);
  151.         Tcl_SetVar(aWindow->interp, "selection", filePtr->name, 1);
  152.         filePtr->selectedP = TRUE;
  153.         selPtr = (WishSelection *)
  154.             malloc(sizeof (WishSelection));
  155.         selPtr->fileP = TRUE;
  156.         selPtr->selected.filePtr = filePtr;
  157.         selPtr->nextPtr = NULL;
  158.         if (lineP) {
  159.             filePtr->lineP = TRUE;
  160.             selPtr->lineP = TRUE;
  161.         } else {
  162.             selPtr->lineP = FALSE;
  163.         }
  164.         if (aWindow->selectionList != NULL) {
  165.             sprintf(wishErrorMsg,
  166.                 "Selection list should have been null and wasn't.");
  167.             Sx_Panic(wishDisplay, wishErrorMsg);
  168.         }
  169.         aWindow->selectionList = selPtr;
  170.         WishRedrawFile(aWindow, filePtr);
  171.         }
  172.         return;
  173.     }
  174.     /* addToP is TRUE */
  175.     if (filePtr->selectedP && !lineP) {
  176.         char    *tclSel;
  177.         char    *removeEntry;
  178.  
  179.         filePtr->selectedP = FALSE;
  180.         filePtr->lineP = FALSE;
  181.         tclSel = Tcl_GetVar(aWindow->interp, "sel", 1);
  182.         if (tclSel == NULL) {
  183.         sprintf(wishErrorMsg, "Tcl selection variable wasn't found.");
  184.         Sx_Panic(wishDisplay, wishErrorMsg);
  185.         }
  186.         removeEntry = (char *) malloc(strlen(tclSel) + 1);
  187.         removeEntry[0] = '\0';
  188.         /* remove it from selection */
  189.         for (selPtr = aWindow->selectionList, backPtr = selPtr;
  190.             selPtr != NULL; selPtr = selPtr->nextPtr) {
  191.         if (!selPtr->fileP) {
  192.             backPtr = selPtr;
  193.             continue;
  194.         }
  195.         if (selPtr->selected.filePtr != filePtr) {
  196.             strcat(removeEntry, filePtr->name);
  197.             strcat(removeEntry, " ");
  198.             backPtr = selPtr;
  199.             continue;
  200.         }
  201.         /* check if nothing is selected anymore */
  202.         if (selPtr == aWindow->selectionList) {
  203.             aWindow->selectionList = selPtr->nextPtr;
  204.         } else {
  205.             backPtr->nextPtr = selPtr->nextPtr;
  206.         }
  207.         free(selPtr);
  208.         WishRedrawFile(aWindow, filePtr);
  209.         break;
  210.         }
  211.         if (removeEntry[strlen(removeEntry) - 1] == ' ') {
  212.         removeEntry[strlen(removeEntry) - 1] = '\0';
  213.         }
  214.         Tcl_SetVar(aWindow->interp, "sel", removeEntry, 1);
  215.         Tcl_SetVar(aWindow->interp, "selection", removeEntry, 1);
  216.         free(removeEntry);
  217.     } else {
  218.         char    *tclSel;
  219.         char    *addEntry;
  220.  
  221.         /* add it to selection */
  222.         /* check if it's already selected and needs lineP changed. */
  223.         if (filePtr->selectedP == TRUE) {
  224. #ifdef NOTDEF
  225.         for (selPtr = aWindow->selectionList; selPtr != NULL;
  226.             selPtr = selPtr->nextPtr) {
  227.             if (selPtr->selected.filePtr == filePtr) {
  228.             break;
  229.             }
  230.         }
  231.         if (selPtr == NULL) {
  232.             sprintf(wishErrorMsg, "%s%s%s", "The selected file `",
  233.                 filePtr->name,
  234.                 "' couldn't be found on the selection list.");
  235.             Sx_Panic(wishDisplay, wishErrorMsg);
  236.         }
  237.         filePtr->lineP = lineP;
  238.         selPtr->lineP = lineP;
  239.         WishRedrawFile(aWindow, filePtr);
  240.         return;
  241. #endif NOTDEF
  242.         }
  243.         /* add new selection */    
  244.         filePtr->selectedP = TRUE;
  245.         if (lineP) {
  246.         filePtr->lineP = TRUE;
  247.         }
  248.         selPtr = (WishSelection *) malloc(sizeof (WishSelection));
  249.         selPtr->fileP = TRUE;
  250.         if (lineP) {
  251.         selPtr->lineP = TRUE;
  252.         } else {
  253.         selPtr->lineP = FALSE;
  254.         }
  255.         selPtr->nextPtr = NULL;
  256.         selPtr->selected.filePtr = filePtr;
  257.         if (aWindow->selectionList == NULL) {
  258.         /*
  259.          * After the first time, Sx_SelectionSet will call
  260.          * WishSelChange, which calls WishClearWholeSelection().
  261.          * This is a warning...
  262.          */
  263.         Sx_SelectionSet(wishDisplay, WishSelFetch, WishSelChange,
  264.             (ClientData) aWindow);
  265.         aWindow->selectionList = selPtr;
  266.         } else {
  267.         for (backPtr = aWindow->selectionList; backPtr->nextPtr != NULL;
  268.             backPtr = backPtr->nextPtr) {
  269.             /* do nothing */
  270.         }
  271.         backPtr->nextPtr = selPtr;
  272.         }
  273.         tclSel = Tcl_GetVar(aWindow->interp, "sel", 1);
  274.         /* space for 2 strings, blank between and null char */
  275.         addEntry = (char *) malloc(strlen(tclSel) +
  276.             strlen(filePtr->name + 2));
  277.         addEntry[0] = '\0';
  278.         strcat(addEntry, tclSel);
  279.         strcat(addEntry, " ");
  280.         strcat(filePtr->name, tclSel);
  281.         Tcl_SetVar(aWindow->interp, "sel", addEntry, 1);
  282.         Tcl_SetVar(aWindow->interp, "selection", addEntry, 1);
  283.         free(addEntry);
  284.         WishRedrawFile(aWindow, filePtr);
  285.         return;
  286.     }
  287.     } else {        /* group selection instead of file selection. */
  288.     /* I don't do tcl selection variable stuff with groups yet. */
  289.     /* lineP stuff doesn't make sense with groups. */
  290.     if (groupPtr->selectedP) {
  291.         /* remove it from selection */
  292.         groupPtr->selectedP = FALSE;
  293.         for (selPtr = aWindow->selectionList, backPtr = selPtr;
  294.             selPtr != NULL; selPtr = selPtr->nextPtr) {
  295.         if (selPtr->fileP) {
  296.             backPtr = selPtr;
  297.             continue;
  298.         }
  299.         if (selPtr->selected.groupPtr != groupPtr) {
  300.             backPtr = selPtr;
  301.             continue;
  302.         }
  303.         /* check if nothing is selected anymore */
  304.         if (selPtr == aWindow->selectionList) {
  305.             aWindow->selectionList = selPtr->nextPtr;
  306.             if (aWindow->selectionList == NULL) {
  307.             /*
  308.              * After the first time, Sx_SelectionSet will call
  309.              * WishSelChange, which calls WishClearWholeSelection().
  310.              * This is a warning...
  311.              */
  312.             Sx_SelectionSet(wishDisplay, WishSelFetch,
  313.                 WishSelChange, (ClientData) aWindow);
  314.             }
  315.         } else {
  316.             backPtr->nextPtr = selPtr->nextPtr;
  317.         }
  318.         free(selPtr);
  319.         /* not yet implemented */
  320.         WishRedrawGroup(aWindow, groupPtr);
  321.         break;
  322.         }
  323.     } else {
  324.         /* add it to selection */
  325.         groupPtr->selectedP = TRUE;
  326.         selPtr = (WishSelection *) malloc(sizeof (WishSelection));
  327.         selPtr->fileP = FALSE;
  328.         selPtr->lineP = FALSE;
  329.         selPtr->nextPtr = NULL;
  330.         selPtr->selected.groupPtr = groupPtr;
  331.         if (aWindow->selectionList == NULL) {
  332.         if (aWindow->selectionList == NULL) {
  333.             /*
  334.              * After the first time, Sx_SelectionSet will call
  335.              * WishSelChange, which calls WishClearWholeSelection().
  336.              * This is a warning...
  337.              */
  338.             Sx_SelectionSet(wishDisplay, WishSelFetch,
  339.                 WishSelChange, (ClientData) aWindow);
  340.         }
  341.         aWindow->selectionList = selPtr;
  342.         } else {
  343.         for (backPtr = aWindow->selectionList; backPtr->nextPtr != NULL;
  344.             backPtr = backPtr->nextPtr) {
  345.             /* do nothing */
  346.         }
  347.         backPtr->nextPtr = selPtr;
  348.         }
  349.         /* not yet implemented */
  350.         WishRedrawGroup(aWindow, groupPtr);
  351.     }
  352.     }
  353.  
  354.     return;
  355. }
  356.  
  357.  
  358.  
  359. /*
  360.  *----------------------------------------------------------------------
  361.  *
  362.  * WishClearWholeSelection --
  363.  *
  364.  *    Empty the selection.
  365.  *
  366.  * Results:
  367.  *    None.
  368.  *
  369.  * Side effects:
  370.  *    The selection list disappears.
  371.  *
  372.  *----------------------------------------------------------------------
  373.  */
  374. void
  375. WishClearWholeSelection(aWindow)
  376.     WishWindow    *aWindow;
  377. {
  378.     WishSelection    *selPtr, *nextPtr;
  379.  
  380.     for (selPtr = aWindow->selectionList; selPtr != NULL; ) {
  381.     if (selPtr->fileP) {
  382.         selPtr->selected.filePtr->selectedP = FALSE;
  383.         selPtr->selected.filePtr->lineP = FALSE;
  384.         WishRedrawFile(aWindow, selPtr->selected.filePtr);
  385.     } else {
  386.         selPtr->selected.groupPtr->selectedP = FALSE;
  387.         /* not yet implemented */
  388.         WishRedrawGroup(aWindow, selPtr->selected.groupPtr);
  389.     }
  390.     nextPtr = selPtr->nextPtr;
  391.     free(selPtr);
  392.     selPtr = nextPtr;
  393.     }
  394.     aWindow->selectionList = NULL;
  395.     Tcl_SetVar(aWindow->interp, "sel", "", 1);
  396.     Tcl_SetVar(aWindow->interp, "selection", "", 1);
  397.  
  398.     return;
  399. }
  400.  
  401.  
  402. /*
  403.  *----------------------------------------------------------------------
  404.  *
  405.  * WishSelFetch --
  406.  *
  407.  *    Called by the Sx selection package when someone wants to know
  408.  *    what's selected.
  409.  *
  410.  * Results:
  411.  *    The number of bytes in the fetched selection, or -1 if there's an error.
  412.  *    (See the Sx_SelectionGet() documentation.)
  413.  *
  414.  * Side effects:
  415.  *    None.
  416.  *
  417.  *----------------------------------------------------------------------
  418.  */
  419. /*ARGSUSED*/
  420. int
  421. WishSelFetch(clientData, askedFormat, firstByte, numBytes, valuePtr,
  422.     formatPtr)
  423.     ClientData    clientData;
  424.     char    *askedFormat;
  425.     int        firstByte;
  426.     int        numBytes;
  427.     char    *valuePtr;
  428.     char    *formatPtr;
  429. {
  430.     WishWindow    *aWindow;
  431.     int            number, n;
  432.     char        *space = NULL;
  433.     char        *copyString;
  434.     WishSelection    *tmpPtr;
  435.  
  436.     /* Use aWindow as the clientData */
  437.     aWindow = (WishWindow *) clientData;
  438.     strncpy(formatPtr, "text", SX_FORMAT_SIZE);
  439.     if (numBytes < 1) {
  440.     return 0;
  441.     }
  442.     if (firstByte < 0) {
  443.     return -1;
  444.     }
  445.     valuePtr[0] = '\0';
  446.  
  447.     /*
  448.      * temporary lunacy test - set number 1 less than numBytes for null char.
  449.      * this fixes stack-trashing problem, but i don't see below where I'm
  450.      * writing off the end of the buffer...
  451.      */
  452.     number = numBytes - 1;
  453.     for (tmpPtr = aWindow->selectionList; tmpPtr != NULL && number > 0;
  454.         tmpPtr = tmpPtr->nextPtr) {
  455.     Boolean    endP = FALSE;
  456.  
  457.     if (!(tmpPtr->selected.filePtr->selectedP)) {
  458.         Sx_Panic(wishDisplay,
  459.             "Inconsistency in selected list discovered.");
  460.     }
  461.     /*
  462.      * Here I'm assuming that if a group is selected, it won't mean
  463.      * to go through and grab all the files...  Maybe it can mean the
  464.      * matching rule or something?  Maybe I need some other selection
  465.      * mechanism for internal group selection?  Or maybe selecting a
  466.      * group is just an interface for actual selection of all the
  467.      * files in it...
  468.      */
  469.     if (!(tmpPtr->fileP)) {
  470.         Sx_Panic(wishDisplay, "Can't fetch group selections yet.");
  471.     }
  472.     if (tmpPtr->nextPtr == NULL) {
  473.         endP = TRUE;
  474.     }
  475.     if (tmpPtr->lineP) {
  476.         int    i;
  477.  
  478.         /*
  479.          * This is how it's done in WishRedrawFile() and
  480.          * the column width calculator, but the calculation should
  481.          * be centralized!
  482.          */
  483.         if (space == NULL) {
  484.         space = (char *) malloc(aWindow->maxEntryWidth + 1);
  485.         }
  486.         strcpy(space, tmpPtr->selected.filePtr->name);
  487.         for (i = strlen(space); i < aWindow->maxEntryWidth + 1;
  488.             i++) {
  489.         space[i] = ' ';
  490.         }
  491.         /*
  492.          * Put in null char so WishGetFileFields concatenates correctly
  493.          * at space[aWindow->maxNameLength + 2].  The 2 is for spaces
  494.          * between the name and info fields.  (Again, from
  495.          * WishRedrawFile().)
  496.          */
  497.         space[aWindow->maxNameLength + 2] = '\0';
  498.         WishGetFileFields(aWindow, tmpPtr->selected.filePtr,
  499.             &(space[aWindow->maxNameLength + 2]));
  500.         copyString = space;
  501.         n = aWindow->maxEntryWidth;
  502.     } else {
  503.         copyString = tmpPtr->selected.filePtr->name;
  504.         n = strlen(copyString);
  505.     }
  506.  
  507.     if (firstByte > 0) {
  508.         if (n <= firstByte) {
  509.         firstByte -= n;
  510.         if (!endP) {        /* for space between strings */
  511.             firstByte--;    /* may leave firstByte -= for space */
  512.         }
  513.         continue;
  514.         } else {
  515.         copyString = copyString + firstByte;
  516.         n -= firstByte;
  517.         firstByte = 0;
  518.         }
  519.     } else if (firstByte < 0) {
  520.         /* firstByte is -1 to show we must first copy a space */
  521.         number--;
  522.         firstByte = 0;
  523.         strcat(valuePtr, " ");
  524.     }
  525.     strncat(valuePtr, copyString, number);
  526.     if (number - n < 0) {
  527.         number = 0;
  528.         break;
  529.     }
  530.     number -= n;
  531.     if (number > 0 && !endP) {
  532.         strcat(valuePtr, " ");
  533.         number--;
  534.     }
  535.     }
  536.     if (space != NULL) {
  537.     free(space);
  538.     space = NULL;
  539.     }
  540.  
  541. /* temporary lunacy, -1 to avoid counting null char if not at end of buffer */
  542.     if (number == 0) {
  543.     return (numBytes - number);
  544.     } else {
  545.     return (numBytes - number - 1);
  546.     }
  547. }
  548.  
  549.  
  550.  
  551. /*
  552.  *----------------------------------------------------------------------
  553.  *
  554.  * WishSelChange --
  555.  *
  556.  *    Called by the Sx selection package whenever the selection changes
  557.  *    out from under us.
  558.  *
  559.  * Results:
  560.  *    None.
  561.  *
  562.  * Side effects:
  563.  *    The list of selected nodes is cleared.
  564.  *
  565.  *----------------------------------------------------------------------
  566.  */
  567. void
  568. WishSelChange(clientData)
  569.     ClientData    clientData;
  570. {
  571.     WishWindow    *aWindow;
  572.  
  573.     aWindow = (WishWindow *) clientData;
  574.     WishClearWholeSelection(aWindow);
  575.  
  576.     return;
  577. }
  578.  
  579.  
  580. /*
  581.  *----------------------------------------------------------------------
  582.  *
  583.  * WishHighlightMovement
  584.  *
  585.  *    Highlight mouse movement to show what file the cursor is over.
  586.  *
  587.  * Results:
  588.  *    None.
  589.  *
  590.  * Side effects:
  591.  *    The display changes.
  592.  *
  593.  *----------------------------------------------------------------------
  594.  */
  595. void
  596. WishHighlightMovement(window, eventPtr)
  597.     Window        window;
  598.     XPointerMovedEvent    *eventPtr;
  599. {
  600.     WishFile    *filePtr;
  601.     WishFile    *last_filePtr = NULL;
  602.     static    int    oldx = -1;    /* Coordinates outside window. */
  603.     static    int    oldy = -1;
  604.     int        x, y;
  605.     WishWindow    *aWindow;
  606.  
  607.     if (eventPtr->type != MotionNotify && eventPtr->type != LeaveNotify) {
  608.     return;
  609.     }
  610.     if (XFindContext(wishDisplay, window, wishWindowContext,
  611.         (caddr_t) &aWindow) != 0) {
  612.     Sx_Panic(wishDisplay, "Fstree didn't recognize given window.");
  613.     }
  614.  
  615.     /* event was selected in display window, so coordinates are ok */
  616.     x = ((XButtonEvent *) eventPtr)->x;
  617.     y = ((XButtonEvent *) eventPtr)->y;
  618.  
  619.     if (eventPtr->type != LeaveNotify) {
  620.     filePtr = WishMapCoordsToFile(aWindow, x, y);
  621.     } else {
  622.     filePtr = NULL;
  623.     }
  624.     last_filePtr = WishMapCoordsToFile(aWindow, oldx, oldy);
  625.  
  626.     if (filePtr == last_filePtr) {    /* leave highlighting alone */
  627.     oldx = x;
  628.     oldy = y;
  629.     return;
  630.     }
  631.     
  632.     /*
  633.      * If we've already toggled a node before, re-toggle it to turn it off
  634.      * as we move away from it.
  635.      */
  636.     if (last_filePtr != NULL) {
  637.     /* I used to toggle highlighting here rather than just turn it off. */
  638.     last_filePtr->highlightP = FALSE;
  639.     WishRedrawFile(aWindow, last_filePtr);
  640.     oldx = oldy = -1;    /* Set to coordinates outside window */
  641.     }
  642.  
  643.     /*
  644.      * If no new file, do nothing.
  645.      */
  646.     if (filePtr == NULL) {
  647.     return;
  648.     }
  649.  
  650.  
  651.     /*
  652.      * toggle new file.
  653.      */
  654.     /*
  655.      * I used to toggle highlighting here rather than just turn it on,
  656.      * but now I don't do selection by toggling, so I needn't here either.
  657.      */
  658.     filePtr->highlightP = TRUE;
  659.     WishRedrawFile(aWindow, filePtr);
  660.     oldx = x;
  661.     oldy = y;
  662.  
  663.     return;
  664. }
  665. @
  666.  
  667.  
  668. 1.3
  669. log
  670. @Fixed many bugs - notifiers no longer trash the display.
  671. @
  672. text
  673. @d18 1
  674. a18 1
  675. static char rcsid[] = "$Header: /a/newcmds/wish/RCS/wishSelect.c,v 1.2 88/11/02 14:50:58 mlgray Exp Locker: mlgray $ SPRITE (Berkeley)";
  676. @
  677.  
  678.  
  679. 1.2
  680. log
  681. @fsflat changed to wish
  682. @
  683. text
  684. @d18 1
  685. a18 1
  686. static char rcsid[] = "$Header: wishSelect.c,v 1.1 88/10/03 12:48:42 mlgray Exp $ SPRITE (Berkeley)";
  687. d67 1
  688. d71 1
  689. @
  690.  
  691.  
  692. 1.1
  693. log
  694. @Initial revision
  695. @
  696. text
  697. @d2 1
  698. a2 1
  699.  * fsflatSelect.c --
  700. d18 1
  701. a18 1
  702. static char rcsid[] = "$Header: fsflatSelect.c,v 1.7 88/06/10 13:15:31 mlgray Exp $ SPRITE (Berkeley)";
  703. d24 1
  704. a24 1
  705. #include "fsflatInt.h"
  706. d29 2
  707. a30 2
  708. extern    void    FsflatSelChange();
  709. extern    int    FsflatSelFetch();
  710. d36 1
  711. a36 1
  712.  * FsflatChangeSelection --
  713. d49 2
  714. a50 2
  715. FsflatChangeSelection(aWindow, clientData, fileP, lineP, addToP)
  716.     FsflatWindow    *aWindow;
  717. d56 3
  718. a58 3
  719.     FsflatFile    *filePtr;
  720.     FsflatGroup    *groupPtr;
  721.     FsflatSelection    *selPtr, *backPtr;
  722. d61 1
  723. a61 1
  724.     filePtr = (FsflatFile *) clientData;
  725. d63 1
  726. a63 1
  727.     groupPtr = (FsflatGroup *) clientData;
  728. d67 1
  729. a67 1
  730.     Sx_Notify(fsflatDisplay, aWindow->surroundingWindow, -1, -1, 0,
  731. d76 1
  732. a76 1
  733.         FsflatClearWholeSelection(aWindow);
  734. d89 1
  735. a89 1
  736.             sprintf(fsflatErrorMsg, "%s%s%s", "The selected file `",
  737. d92 1
  738. a92 1
  739.             Sx_Panic(fsflatDisplay, fsflatErrorMsg);
  740. d96 1
  741. a96 1
  742.             FsflatRedrawFile(aWindow, filePtr);
  743. d101 1
  744. a101 1
  745.         FsflatClearWholeSelection(aWindow);
  746. d104 1
  747. a104 1
  748.          * FsflatSelChange, which calls FsflatClearWholeSelection().
  749. d107 1
  750. a107 1
  751.         Sx_SelectionSet(fsflatDisplay, FsflatSelFetch, FsflatSelChange,
  752. d112 2
  753. a113 2
  754.         selPtr = (FsflatSelection *)
  755.             malloc(sizeof (FsflatSelection));
  756. d124 1
  757. a124 1
  758.             sprintf(fsflatErrorMsg,
  759. d126 1
  760. a126 1
  761.             Sx_Panic(fsflatDisplay, fsflatErrorMsg);
  762. d129 1
  763. a129 1
  764.         FsflatRedrawFile(aWindow, filePtr);
  765. d142 2
  766. a143 2
  767.         sprintf(fsflatErrorMsg, "Tcl selection variable wasn't found.");
  768.         Sx_Panic(fsflatDisplay, fsflatErrorMsg);
  769. d167 1
  770. a167 1
  771.         FsflatRedrawFile(aWindow, filePtr);
  772. d191 1
  773. a191 1
  774.             sprintf(fsflatErrorMsg, "%s%s%s", "The selected file `",
  775. d194 1
  776. a194 1
  777.             Sx_Panic(fsflatDisplay, fsflatErrorMsg);
  778. d198 1
  779. a198 1
  780.         FsflatRedrawFile(aWindow, filePtr);
  781. d207 1
  782. a207 1
  783.         selPtr = (FsflatSelection *) malloc(sizeof (FsflatSelection));
  784. d219 1
  785. a219 1
  786.          * FsflatSelChange, which calls FsflatClearWholeSelection().
  787. d222 1
  788. a222 1
  789.         Sx_SelectionSet(fsflatDisplay, FsflatSelFetch, FsflatSelChange,
  790. d243 1
  791. a243 1
  792.         FsflatRedrawFile(aWindow, filePtr);
  793. d268 1
  794. a268 1
  795.              * FsflatSelChange, which calls FsflatClearWholeSelection().
  796. d271 2
  797. a272 2
  798.             Sx_SelectionSet(fsflatDisplay, FsflatSelFetch,
  799.                 FsflatSelChange, (ClientData) aWindow);
  800. d279 1
  801. a279 1
  802.         FsflatRedrawGroup(aWindow, groupPtr);
  803. d285 1
  804. a285 1
  805.         selPtr = (FsflatSelection *) malloc(sizeof (FsflatSelection));
  806. d294 1
  807. a294 1
  808.              * FsflatSelChange, which calls FsflatClearWholeSelection().
  809. d297 2
  810. a298 2
  811.             Sx_SelectionSet(fsflatDisplay, FsflatSelFetch,
  812.                 FsflatSelChange, (ClientData) aWindow);
  813. d309 1
  814. a309 1
  815.         FsflatRedrawGroup(aWindow, groupPtr);
  816. d321 1
  817. a321 1
  818.  * FsflatClearWholeSelection --
  819. d334 2
  820. a335 2
  821. FsflatClearWholeSelection(aWindow)
  822.     FsflatWindow    *aWindow;
  823. d337 1
  824. a337 1
  825.     FsflatSelection    *selPtr, *nextPtr;
  826. d343 1
  827. a343 1
  828.         FsflatRedrawFile(aWindow, selPtr->selected.filePtr);
  829. d347 1
  830. a347 1
  831.         FsflatRedrawGroup(aWindow, selPtr->selected.groupPtr);
  832. d364 1
  833. a364 1
  834.  * FsflatSelFetch --
  835. d380 1
  836. a380 1
  837. FsflatSelFetch(clientData, askedFormat, firstByte, numBytes, valuePtr,
  838. d389 1
  839. a389 1
  840.     FsflatWindow    *aWindow;
  841. d393 1
  842. a393 1
  843.     FsflatSelection    *tmpPtr;
  844. d396 1
  845. a396 1
  846.     aWindow = (FsflatWindow *) clientData;
  847. d417 1
  848. a417 1
  849.         Sx_Panic(fsflatDisplay,
  850. d429 1
  851. a429 1
  852.         Sx_Panic(fsflatDisplay, "Can't fetch group selections yet.");
  853. d438 1
  854. a438 1
  855.          * This is how it's done in FsflatRedrawFile() and
  856. d451 1
  857. a451 1
  858.          * Put in null char so FsflatGetFileFields concatenates correctly
  859. d454 1
  860. a454 1
  861.          * FsflatRedrawFile().)
  862. d457 1
  863. a457 1
  864.         FsflatGetFileFields(aWindow, tmpPtr->selected.filePtr,
  865. d513 1
  866. a513 1
  867.  * FsflatSelChange --
  868. d527 1
  869. a527 1
  870. FsflatSelChange(clientData)
  871. d530 1
  872. a530 1
  873.     FsflatWindow    *aWindow;
  874. d532 2
  875. a533 2
  876.     aWindow = (FsflatWindow *) clientData;
  877.     FsflatClearWholeSelection(aWindow);
  878. d542 1
  879. a542 1
  880.  * FsflatHighlightMovement
  881. d555 1
  882. a555 1
  883. FsflatHighlightMovement(window, eventPtr)
  884. d559 2
  885. a560 2
  886.     FsflatFile    *filePtr;
  887.     FsflatFile    *last_filePtr = NULL;
  888. d564 1
  889. a564 1
  890.     FsflatWindow    *aWindow;
  891. d569 1
  892. a569 1
  893.     if (XFindContext(fsflatDisplay, window, fsflatWindowContext,
  894. d571 1
  895. a571 1
  896.     Sx_Panic(fsflatDisplay, "Fstree didn't recognize given window.");
  897. d579 1
  898. a579 1
  899.     filePtr = FsflatMapCoordsToFile(aWindow, x, y);
  900. d583 1
  901. a583 1
  902.     last_filePtr = FsflatMapCoordsToFile(aWindow, oldx, oldy);
  903. d598 1
  904. a598 1
  905.     FsflatRedrawFile(aWindow, last_filePtr);
  906. d618 1
  907. a618 1
  908.     FsflatRedrawFile(aWindow, filePtr);
  909. @
  910.